﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Compilation;
using System.Web.Security;
using System.Web.SessionState;
using WebApplication1.App_Start;

namespace WebApplication1
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            //相当注册路由,当然 这里只是反射 所有的controller 类型保存起来
            var assemblies = BuildManager.GetReferencedAssemblies();
            var RoutingInfor = new RoutingInfo();
            foreach (Assembly assembly in assemblies)
            {
                var types = assembly.GetTypes();
                foreach (var type in types)
                {
                    if (type.IsClass & !type.IsAbstract && type.IsPublic && typeof(IController).IsAssignableFrom(type))
                    {
                        RoutingInfor.AddType(type.Name.ToLower(), type);
                    }
                }
            }
        }

    }
}